package com.wm.singleton;

/**
 * @ClassName: Singleton_02
 * @Description: 懒汉模式（线程安全）
 * @Author: WM
 * @Date: 2022/12/19 19:41
 */
public class Singleton_02 {
    private static Singleton_02 instance;

    private Singleton_02() {

    }

    // 加锁
    public static synchronized Singleton_02 getInstance() {
        if (instance != null) {
            return instance;
        }
        instance = new Singleton_02();
        return instance;
    }
}
